/*
 * Candy Boxes Problem
 *
 * Author: Yue ZHAO
 *
 * Language: C++
 */


#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib> // atoi
#include <vector>
#include <sstream>

using namespace std;

class CandyBoxes {
public:
  int remainingCandies(vector<int> candies) {
    if (candies.size() == 0) return -1;

    int ret = candies[0];

    for (int i=1; i<candies.size(); i++) 
      ret = gcd(candies[i], ret);

    return ret;
  }

  int gcd(int a, int b) {
    int c = a % b;
    if (c == 0) return b;
    return gcd(b, c);
  }

};

int main(int argc, char **argv) {
  CandyBoxes cb;
  vector<int> candies;
  if (argc > 1) { 
    // read from the cmd line
    for (int i=1; i<argc; i++) {
      candies.push_back(atoi(argv[i]));
    }
  } else {
    string str;
    char buff[128];
    cout << "Candies: "; 
    cin.getline(buff, 128);
    stringstream ss(buff);
    while (ss.getline(buff, 128, ' ')) {
      int tmp = atoi(buff);
      if (tmp == 0) // check if the number is valid
        continue;
      candies.push_back(tmp);
    }
  }
    
  cout << cb.remainingCandies(candies) << endl;
  
  return 0;
}
